import { GameEngine } from "./engine/GameEngine";
import { DisableOnClick } from "./DisableOnClick";
import { Sound } from "./Sound";
import { Live } from "./Live";
import { Score } from "./Score";
import { GamePlaySystem } from "./GamePlaySystem";
import { PhysicalSystem } from "./engine/box2d/PhysicalSystem";
import { Follow } from "./Follow";
import { UIfollow } from "./UIfollow";
import { LifeCollider } from "./LifeCollider";

const engine = new GameEngine();
if (engine.runMode === 'running') {
    const gamePlaySystem = new GamePlaySystem();
    engine.registerSystem(gamePlaySystem);
    engine.registerSystem(new PhysicalSystem(false, gamePlaySystem))
}
else {
    engine.registerSystem(new PhysicalSystem(true))
}

engine.start(['assets/click/menu.png', 'assets/click/win.png', 'assets/click/lose.png', 'assets/click/voice.png', 'assets/click/help.png', 'assets/click/instruction.png',
    'assets/click/map.png', 'assets/click/bing.png', 'assets/click/huo.png', 'assets/click/tu.png', 'assets/click/return.png',
    'assets/splinter.png', 'assets/scene1/diamond.png', 'assets/scene1/background.png', 'assets/scene1/stone.png', 'assets/scene1/gold.png',
    'assets/scene1/wall_left.png', 'assets/scene1/wall_right.png', 'assets/scene1/door.png', 'assets/scene1/brick1.png', 'assets/scene1/brick2.png',
    'assets/scene2/wall_left.png', 'assets/scene2/wall_right.png', 'assets/scene2/door.png', 'assets/scene2/background.png',
    'assets/scene2/ice.png', 'assets/scene2/beike.png', 'assets/scene2/beike2.png',
    'assets/scene3/background3.png', 'assets/scene3/cube.png', 'assets/scene3/qiang.png', 'assets/scene3/qiang2.png', 'assets/scene3/door3.png', 'assets/scene3/heimeiqiu.png', 'assets/scene3/shuidi.png',
    'assets/rockman/zhezhao.png', 'assets/rockman/jump.png',
    'assets/rockman/walk1.png', 'assets/rockman/walk2.png', 'assets/rockman/walk3.png', 'assets/rockman/walk4.png', 'assets/rockman/walk5.png', 'assets/rockman/walk6.png',
    'assets/sceneUI/life0.png', 'assets/sceneUI/life1.png', 'assets/sceneUI/life2.png', 'assets/sceneUI/life3.png', 'assets/sceneUI/star.png'],
    ['stage.json', 'scene.json', 'scene2.json', 'scene3.json', 'select.json', 'ui.json', 'win.json', 'menu.json', 'lose.json'], 'stage.json');

window['engine'] = engine;

engine.registerBehaviour(Sound);
engine.registerBehaviour(DisableOnClick);
engine.registerBehaviour(Live);
engine.registerBehaviour(Score);
engine.registerBehaviour(Follow);
engine.registerBehaviour(UIfollow);
engine.registerBehaviour(LifeCollider)